<?php


/** 
 * 弹幕操作
 * @author Legend. <xcx_legender@qq.com>
 * @param 
 * @return 
 */

namespace Api\Controller;

class BarrageController extends UserBaseController 
{	
	/**
	*评论的事件对象
	*/
	protected $eventObj = '';

	/**
	*参数初始化
	*/
	protected function _initialize(){
		parent::_initialize();
		$this->eventObj = A('Api/Barrage', 'Event');
	}

	/**
	*新增弹幕信息
	*@return json
	*/
	public function add(){
		$data['text'] = I('text','','trim');
		$data['startTime'] = I('startTime', 0, 'intval');
		$data['aliveTime'] = I('aliveTime', 0, 'intval');
		$data['textColor'] = I('textColor','','trim');
		$video_id = I('video_id', 0, 'intval');
		$bEvent = A('Api/Barrage', 'Event');
		$user['uid'] = UID;
		if ($barrage = $bEvent->add($video_id, $user, $data))
		{
			unset($barrage['_id']);
			$this->success('发布成功', $barrage);
		}
		else
		{
			$this->error($bEvent->error['code'], $bEvent->error['info']);
		}
	}

}